<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>selectDept</title>
	
	<style>
		body {
		  padding-top: 3.5rem;
		}
		img {
			width:100px;
			height:100px;
		}
	</style>
	
    <!-- Bootstrap core CSS -->
    <link href="./styles/bootstrap.min.css" rel="stylesheet">
  </head>

  <body>

    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
          <ol class="breadcrumb">
		    <li class="breadcrumb-item active" aria-current="page">电子支付:选择机构</li>
	      </ol>
        </ul>
        <form class="form-inline my-2 my-lg-0">
          <input class="form-control mr-sm-2" type="text" placeholder="机构名称" aria-label="Search">
          <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
        </form>
      </div>
    </nav>

    <main role="main">

      <!-- Main jumbotron for a primary marketing message or call to action -->
      <div class="jumbotron">
        <div class="container">
          <h1 class="display-3">Hello, Guys!</h1>
          <h3>You can see the information of all third department at the bottom,And then choose one.</h3>
		  <h3>Be careful!  Alipay is not the same as the others.</h3>
        </div>
      </div>

      <div class="container" style="text-align:center">
        <!-- Example row of columns -->
        <div class="row">
        </div>
        <hr>
      </div> <!-- /container -->
    </main>
    <footer class="container">
      <p>&copy; Company 电子支付</p>
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/javascript" src="js/jquery-slim.min.js"></script>
    <script type="text/javascript" src="js/popper.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/login.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/cookie_util.js"></script>
    <script type="text/javascript" src="js/json2.js"></script>
    <script type="text/javascript">
    	var deptTemplate = '<div class="col-md-4">'+
								'<img src="./image/[picName].jpg" class="rounded-circle border">'+
								'<h2 id="deptName">[departmentName]</h2>'+
								'<p>[departmentId]</p>'+
								'<p>[deptId]</p>'+
								'<p><a class="btn btn-secondary" href="#" onclick="selectVersion([seq]);return false;" role="button">Select &raquo;</a></p>'+
							'</div>'
    	var deptList;
    	$(function(){
    		loadDept();
    	});
    	
    	function loadDept(){
    		deptList = localStorage.getItem("deptList");
			//将取出来的json字符串转换为json对象
    		deptList = JSON.parse(deptList);
    		for(var i = 0 ; i < deptList.length ; i++){
    			
    			var deptId = deptList[i].deptId;
    			var departmentName = deptList[i].departmentName;
    			var departmentId = deptList[i].departmentId;
    			
    			var div = deptTemplate.replace('[picName]',deptId)
									  .replace('[departmentName]',departmentName)
									  .replace('[deptId]',deptId)
									  .replace('[departmentId]',departmentId)
									  .replace('[seq]',i);
				$(".row").prepend(div);
    		}
    	}
							
    	function selectVersion(i){
    		/* addCookie("deptId",deptList[i].deptId);*/
    		localStorage.setItem("departmentName", deptList[i].departmentName);
    		localStorage.setItem("departmentId", deptList[i].departmentId);
    		location.href="selectEdition2.html";
    	}
    </script>
  </body>
</html>
